package com.qianfeng.openplatform.servertest.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 江江
 * @Date 2020/7/24 9:57
 */
@RestController
public class TestController {
    @RequestMapping("/test01")
    public String testMethod1(){
        return "test01-->no method params";
    }
    @RequestMapping("/test01/{name}")
    public String testMethod1(@PathVariable String name){
        //@PathVariable 在url里面些() /
        //@RequestParam 加载url后面()  &name =
        return "test01-->no method params: "+name;
    }
    @RequestMapping("/test01/{name}/{age}")
    public String testMethod1(@PathVariable String name,@PathVariable int age){
        //@PathVariable 在url里面些() /
        //@RequestParam 加载url后面()  &name =
        return "test01-->no method params: "+name+" and Age: "+age;
    }

    @RequestMapping("/test01/hehe")
    public String testMethod2(@RequestParam String name){
        //@PathVariable 在url里面些() /
        //@RequestParam 加载url后面()  &name =jiangruiqi
        return "test02-->no method params: "+name;
    }
    @RequestMapping("/test01/hfqf")
    //http://www.openapi.sys/openapi?method=servertest05&appkey=msmsms23330
    public Map<String,Object> testMethod3(){
        Map<String,Object> map=new HashMap<>();
        map.put("userName","张三");
        map.put("age",30);
        map.put("address","安徽省合肥市东方广场");
        map.put("phone","13838384388");
        return map;
    }
}
